//
//  STBView.m
//  NuwaRobot
//
//  Created by Kendama on 2017/12/5.
//  Copyright © 2017年 Kendama. All rights reserved.
//

#import "STBView.h"
#import "NumberMenuView.h"

@interface STBView ()<NumberMenuViewDelegate>

@end

@implementation STBView

- (void)didClickButton:(UIButton *)sender
{
    if ([self.delegate respondsToSelector:@selector(stbViewSelectedIndex:)])
    {
        [self.delegate stbViewSelectedIndex:sender.tag];
    }
}

- (void)numberMenuViewSelectedIndex:(NSInteger)index
{
    if ([self.delegate respondsToSelector:@selector(stbViewSelectedIndex:)])
    {
        [self.delegate stbViewSelectedIndex:index];
    }
}

- (NumberMenuView *)numberMenuView
{
    if(!_numberMenuView)
    {
        UIView *superView = self;
        _numberMenuView = [[NumberMenuView alloc]init];
        [superView addSubview:_numberMenuView];
        _numberMenuView.delegate = self;
    }
    return _numberMenuView;
}

- (UIButton *)homeButton
{
    if(!_homeButton)
    {
        UIView *superView = self;
        _homeButton = [[UIButton alloc]init];
        [superView addSubview:_homeButton];
        [_homeButton setTitle:@"主页" forState:UIControlStateNormal];
        [_homeButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        _homeButton.layer.cornerRadius = 3;
        [_homeButton.titleLabel setFont:fontCommonSize];
//        [_homeButton setBackgroundColor:rgba(65,98,170,1)];
        [_homeButton setBackgroundImage:imageWithName(@"number_button_bg") forState:UIControlStateNormal];
        _homeButton.tag = 91;
        [_homeButton addTarget:self action:@selector(didClickButton:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _homeButton;
}
- (UIButton *)AVButton
{
    if(!_AVButton)
    {
        UIView *superView = self;
        _AVButton = [[UIButton alloc]init];
        [superView addSubview:_AVButton];
        [_AVButton setTitle:@"AV/TV" forState:UIControlStateNormal];
        [_AVButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        _AVButton.layer.cornerRadius = 3;
        [_AVButton.titleLabel setFont:fontCommonSize];
//        [_AVButton setBackgroundColor:rgba(65,98,170,1)];
        [_AVButton setBackgroundImage:imageWithName(@"number_button_bg") forState:UIControlStateNormal];
        _AVButton.tag = 93;
        [_AVButton addTarget:self action:@selector(didClickButton:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _AVButton;
}




- (void)masLayoutSubview
{
    __weak UIView *superView = self;
    
    [self.numberMenuView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(superView.mas_top).with.offset(px1920Height(250));
        make.left.mas_equalTo(superView.mas_left).with.offset(px1080Width(90));
        make.right.mas_equalTo(superView.mas_right).with.offset(-px1080Width(90));
        make.height.mas_equalTo(px1920Height(1452));
    }];
    
    [self.homeButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.numberMenuView.mas_bottom).with.offset(px1920Height(50));
        make.left.mas_equalTo(self.numberMenuView.mas_left);
        make.width.mas_equalTo(px1080Width(240));
        make.height.mas_equalTo(px1920Height(113));
    }];
    
    [self.AVButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.numberMenuView.mas_bottom).with.offset(px1920Height(50));
        make.right.mas_equalTo(self.numberMenuView.mas_right);
        make.width.mas_equalTo(px1080Width(240));
        make.height.mas_equalTo(px1920Height(113));
    }];
    
}

@end
